package com.wrupple.muba.catalogs.client.widgets.fields.cells;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.inject.Provider;
import com.wrupple.muba.catalogs.client.activity.process.state.ContentLoadingState;
import com.wrupple.muba.catalogs.client.activity.process.task.CatalogInteractionState.Mode;
import com.wrupple.muba.catalogs.client.cms.service.CatalogManagementSystem;
import com.wrupple.muba.catalogs.client.widgets.fields.cells.templates.CatalogImageTemplate;
import com.wrupple.muba.common.shared.State.ProcessManager;
import com.wrupple.vegetate.domain.FieldDescriptor;

public class ImageKeyCell extends GenericKeyCell {
	CatalogImageTemplate imageTemplate;
	public ImageKeyCell(EventBus bus, ProcessManager pm, FieldDescriptor d,
			Mode mode, CatalogManagementSystem cms,
			Provider<ContentLoadingState> contentLoadingState) {
		super(bus, pm, d, mode, cms, contentLoadingState);
		imageTemplate = GWT.create(CatalogImageTemplate.class);
	}

	@Override
	protected void renderReadOnly(
			com.google.gwt.cell.client.Cell.Context context,
			String value,
			SafeHtmlBuilder sb,
			com.wrupple.muba.catalogs.client.widgets.fields.cells.AbstractEditableField.FieldData<String> viewData) {
		if(value==null){
		}else{
			SafeHtml rendered = imageTemplate.smallImageOutput(value);
			sb.append(rendered);
		}
	}
}
